<template>
  <div class="container">
    <div class="department-seeting">
        <div class="panel-box">
            <div class="i-cell i-input">
                <div class="i-input-title">法定全称：</div>
                <input class='i-input-input' type="text" v-model="editInfo.F_FullName" placeholder="请输入营业执照名称">
            </div>
            <div class="i-cell i-input">
                <div class="i-input-title">简 称：</div>
                <input class='i-input-input' type="text" v-model="editInfo.F_ShortName" placeholder="请输入简称">
            </div>
            <div class="i-cell i-cell-access" @click="chooseDep">
                <div class="i-input-bd">
                    <div class="i-cell-text">选择上级公司</div>
                </div>
                <div class="i-cell-ft">{{parentName}}</div>
            </div>
            <!-- <i-input v-model="editInfo.F_FullName" title="法定全称：" placeholder="请输入法定全称" />
            <i-input v-model="editInfo.F_ShortName" title="简称：" placeholder="请输入简称"/>
            <i-cell title="选择上级公司" v-model="parentName" is-link url='/pages/center/chooseDepartment'></i-cell> -->
        </div>
        <buttomBtn title="保存" @handleClick='handleClick'></buttomBtn>
    </div>
  </div>
</template>

<script>
import search from '@/components/search'
import buttomBtn from '@/components/Bbutton'
import noResult from '@/components/no-result'
import { mapState } from 'vuex'
import { updateOrganize } from 'api/api'
export default {
    data () {
        return {
            editInfo: {
                F_Id: '',
                F_FullName: '',
                F_ShortName: ''
            },
            parentName: '',
            parentId: ''
        }
    },

    components: {
        search,
        noResult,
        buttomBtn
    },

    methods: {
        bindViewTap () {
            const url = '../logs/index'
            wx.navigateTo({ url })
        },
        handleClick () {
            let orgEditInfo = {
                'id': this.editInfo.F_Id,
                'parentId': this.parentId,
                'fullName': this.editInfo.F_FullName,
                'shortName': this.editInfo.F_ShortName
            }
            updateOrganize(orgEditInfo)
                .then(res => {
                    console.log(res)
                    this.$store.commit('org/SETEDITSUBCHOOSEINFO', {})
                    wx.showToast({
                        title: '保存成功',
                        icon: 'none',
                        mask: true
                    })
                    wx.navigateBack({
                        delta: 1
                    })
                })
        },
        chooseDep () {
            const url = '/pages/center/chooseDepartment?type=editSub'
            wx.navigateTo({ url })
        }
    },
    computed: {
        ...mapState({
            editSubChooseInfo: state => state.org.editSubChooseInfo
        })
    },
    onShow () {
        console.log(this.$mp.query)
        this.editInfo = JSON.parse(this.$mp.query.editInfo)
        this.parentName = this.editSubChooseInfo.F_FullName
        this.parentId = this.editSubChooseInfo.F_Id
    }
}
</script>

<style lang='stylus' scoped>
.department-seeting
    width 750rpx
    min-height 100vh
    display flex
    flex-direction column
    justify-content space-between
    .fixed
        position fixed
        top 0
        width 100%
    .i-cell
        border-bottom:1px solid #efefef
        position:relative
        padding:12px 15px
        display:flex
        background:#fff
        align-items:center
        line-height:1.4
        font-size:14px
        overflow:hidden
        .i-input-bd
            flex 1
            .i-cell-text
                line-height:24px
                font-size:14px
        .i-cell-ft
            position: relative
            text-align: right
            color: #495060
        &.i-cell-access
            .i-cell-ft
                padding-right: 13px
                &:after
                    content: " "
                    display: inline-block
                    width: 6px
                    height: 6px
                    position: absolute
                    top: 50%
                    right: 2px
                    border-width: 2px 2px 0 0
                    border-color: #dddee1
                    border-style: solid
                    transform: translateY(-50%) matrix(.71, .71, -.71, .71, 0, 0)
    .i-input
        padding:7px 15px;
        color:#495060;
        .i-input-title
            min-width:65px
            padding-right:10px
        .i-input-input
            flex:1;
            line-height:1.6;
            padding:4px 0;
            min-height:22px;
            height:auto;
            font-size:14px;
</style>
